import type { UserInfo } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'cp-user',
  () => {
    //1.用户信息
    const user = ref<UserInfo>()
    //设置用户信息
    const setUser = (data: UserInfo) => {
      console.log(data)
      user.value = data
    }
    //删除用户信息
    const delUser = () => {
      user.value = undefined
    }
    return { user, setUser, delUser }
  },
  {
    persist: true
  }
)
